package com.knowledge.review.designPatterns.structuralpattern.bridgepattern;

import lombok.AllArgsConstructor;

// 视频接口
public interface Video {
    void decode(String fileName);
}
 
// MP4格式类
class Mp4 implements Video{
    @Override
    public void decode(String fileName) {
        System.out.println("MP4视频文件："+ fileName);
    }
}
// RMVB格式类
class Rmvb implements Video{
    @Override
    public void decode(String fileName) {
        System.out.println("rmvb文件：" + fileName);
    }
}
// 操作系统抽象类
@AllArgsConstructor
abstract class OperatingSystem {
    Video video;
    public abstract void play(String fileName);
 
}
// iOS系统
class Ios extends OperatingSystem {
    public Ios(Video video){
        super(video);
    }
    @Override
    public void play(String fileName) {
        video.decode(fileName);
    }
}
// windows系统
class Windows extends OperatingSystem {
    public Windows(Video video){
        super(video);
    }
    @Override
    public void play(String fileName) {
        video.decode(fileName);
    }
}

class Test{
    public static void main(String[] args) {
        Video mp4 = new Mp4();
        Video rmvb = new Rmvb();

        OperatingSystem ios = new Ios(mp4);
        OperatingSystem windows = new Windows(rmvb);

        ios.play("video1.mp4");
        windows.play("video2.rmvb");
    }
}